package com.pzy.base.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import com.mybatisflex.core.keygen.KeyGenerators;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;

import java.io.Serializable;
import java.util.Date;

@Builder
@NoArgsConstructor
@AllArgsConstructor
@Getter
@Setter
public class BaseEntity implements Serializable {
    /**
     * 主键ID，并指定生成器为雪花ID
     */
    @Id(keyType = KeyType.Generator, value = KeyGenerators.snowFlakeId)
    @Schema(description = "主键")
    private String id;

    /**
     * 创建时间
     * ---
     * 默认为当前时间. 由系统自动填充
     */
    @Column(value = "created_time", onInsertValue = "now()")
    @Schema(description = "创建时间. 默认为当前时间. 由系统自动填充", format = "YYYY-MM-DD HH:mm:ss", nullable = true)
    @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createdTime;

    /**
     * 更新时间
     * ---
     * 默认为null. 尽在更新操作时, 由系统自动填充
     */
    @Column(value = "updated_time", onUpdateValue = "now()")
    @Schema(description = "更新时间. 默认为null. 尽在更新操作时, 由系统自动填充", format = "YYYY-MM-DD HH:mm:ss", nullable = true)
    @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private Date updatedTime;
}
